package com.edu.whu.entity;

import com.edu.whu.service.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Id;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class UserInfo {
    @Id
    private String account;
    private String name;
    private String password;

    public void validate() throws ServiceException {
        if (account.length() > 20 || name.length() > 10 || password.length() > 20) {
            throw new ServiceException("用户信息不合规范");
        }
    }
}
